package com.csgc.camera.storage

import com.csgc.camera.storage.base.BasePreferences

class SettingPreference private constructor(preferenceID:String): BasePreferences(preferenceID ) {

    companion object{

        private const val KEY_REFERENCE_LINE = "ReferenceLine"
        private const val KEY_CAMERA_VIBRATING = "camera_vibrating"
        private const val KEY_TAKE_CAMERA_SOUND = "take_camera_sound"
        private const val KEY_AUTO_SAVE_IMAGE = "auto_save_image"
        private const val KEY_LOGO_WATER_MARK = "key_logo_water_mark"
        //非会员拍照限制3张
        private const val KEY_TAKE_PHOTO_COUNT = "take_photo_count"

        val instance by lazy(LazyThreadSafetyMode.NONE){
            SettingPreference("settings")
        }
    }


    //参考线
    fun setReferenceLine(status:Boolean){
        setBoolean(KEY_REFERENCE_LINE,status)
    }
    fun isReferenceLine():Boolean{
        return getBoolean(KEY_REFERENCE_LINE,false)?:false
    }

    //震动
    fun setCameraVibrating(status:Boolean){
        setBoolean(KEY_CAMERA_VIBRATING,status)
    }
    fun isCameraVibrating():Boolean{
        return getBoolean(KEY_CAMERA_VIBRATING,false)?:false
    }

    //拍照声音
    fun setTakeCameraSound(status: Boolean){
        setBoolean(KEY_TAKE_CAMERA_SOUND,status)
    }
    fun isTakeCameraSound():Boolean{
        return getBoolean(KEY_TAKE_CAMERA_SOUND,true)?:true
    }

    //是否自动保存图片
    fun setAutoSaveImage(status: Boolean){
        setBoolean(KEY_AUTO_SAVE_IMAGE,status)
    }
    fun isAutoSaveImage():Boolean{
        return getBoolean(KEY_AUTO_SAVE_IMAGE,true)?:true
    }

    //logo水印
    fun setLogoWaterMark(status: Boolean){
        setBoolean(KEY_LOGO_WATER_MARK,status)
    }
    fun isLogoWaterMark():Boolean{
        return getBoolean(KEY_LOGO_WATER_MARK,true)?:true
    }

    fun setTakePhoto(){
        setInt(KEY_TAKE_PHOTO_COUNT,getTakePhotoCount()+1)
    }
    fun getTakePhotoCount():Int{
        return getInt(KEY_TAKE_PHOTO_COUNT,0)?:0
    }
}